import java.util.Scanner;

public class Day_8_1_两种排序方法 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] str = new String[n];
        for(int i = 0; i < n; ++i){
            str[i] = sc.nextLine();
        }
        if(isLexicographically(str) && isLengths(str)){
            System.out.println("both");
        }else if(isLexicographically(str)){
            System.out.println("lexicographically");
        }else if(isLengths(str)){
            System.out.println("length");
        }else {
            System.out.println("no");
        }
    }
    private static boolean isLexicographically(String[] str) {
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].compareTo(str[i+1])> 0){
                return false;
            }
        }
        return true;
    }

    private static boolean isLengths(String[] str) {
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].length() > str[i+1].length()){
                return false;
            }
        }
        return true;
    }



}
